# coding=utf-8
# namedtuple类位于collections模块,有了namedtuple后通过属性访问数据
# 能够让我们的代码更加的直观,更好维护。
from collections import namedtuple
SSDParams = namedtuple('SSDParameters',['img_shape',
										'num_classes',
										'no_annotation_label',
										'feat_layers',
										'feat_shapes',
										'anchor_size_bounds',
										'anchor_sizes',
										'anchor_ratios',
										'anchor_steps',
										'anchor_offset',
										'normalizations',
										'prior_scaling'
										])
	
default_params = SSDParams (
    img_shape=(300, 300),
    # 对于VOC，20类目标，加上背景，总该21类
    num_classes = 21,
    no_annotation_label=21,
    # 将从以下特征金字塔处（feature maps）获取数据
    feat_layers=['block4', 'block7', 'block8', 'block9', 'block10', 'block11'],
    # feature maps尺寸
    feat_shapes=[(38, 38), 
                 (19, 19), 
                 (10, 10), 
                 (5, 5), 
                 (3, 3), 
                 (1, 1)],
    anchor_size_bounds=[0.15, 0.90],
    # 根据论文公式4：anchor_sizes是由anchor_size_bounds给定的参数，以及image_shape计算
    # 出来的,但代码中anchor_sizes直接初始化了，而且数据同公式计算在结果有差别
    anchor_sizes=[( 21.,  45.),
                  ( 45.,  99.),
                  ( 99., 153.),
                  (153., 207.),
                  (207., 261.),
                  (261., 315.)],
    # 各feature maps上的prior boxes的宽高比
    anchor_ratios=[[2, .5],
                   [2, .5, 3, 1./3],
                   [2, .5, 3, 1./3],
                   [2, .5, 3, 1./3],
                   [2, .5],
                   [2, .5]],
    # 某层feature maps上每个位置对应的anchor boxes的数目为：
    #len(anchor_sizes) + len(anchor_ratios)
    anchor_steps  = [8, 16, 32, 64, 100, 300],
    anchor_offset = 0.5,
    normalizations= [20, -1, -1, -1, -1, -1],
    prior_scaling = [0.1, 0.1, 0.2, 0.2]
    )


if __name__ == '__main__':
	print default_params
	
	
	
	
	
